<%--
  Created by IntelliJ IDEA.
  User: zjk
  Date: 2018-08-03
  Time: 21:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>表格模板</title>
    <link rel="shortcut icon" href="easyui/css/images/favicon.ico"/>
    <link rel="stylesheet" href="css/flipclock.css">
    <link href="css/CalcSS3.css" rel="stylesheet" type="text/css"/>
    <link href="css/index.css" rel="stylesheet" type="text/css"/>
    <link href="easyui/css/easyui.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/easyui_animation.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/easyui_plus.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/insdep_theme_default.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/icon.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">


    <!-- 引入 ECharts 文件 -->
    <script src="js/echarts.js"></script>
    <!--放入自定义的图表-->
    <script src="js/monitor.js"></script>
    <script type="text/javascript" src="easyui/js/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui/js/jquery.insdep-extend.min.js"></script>
    <script type="text/javascript" src="js/utils/DateFormate.js"></script>


</head>
<body>
<style>
    .by{
        padding: 10px;
        text-align: center;
    }
</style>
<!-- 引入公用表格和表单样式 -->
<link href="css/utils/utilsDatagrid.css" rel="stylesheet" type="text/css">
<link href="css/utils/utilsForm.css" rel="stylesheet" type="text/css">
<!-- 引入 详情样式-->
<link href="css/utils/utilsDetails.css" rel="stylesheet" type="text/css">


<div class="easyui-layout"  data-options="fit:true, border:false">
    <div data-options="region:'north', border:false,height:200" style="padding:5px;">
        <table id="zjk-salePlan-dg" class="easyui-datagrid table-chance"  data-options="fit:true,striped:true,height:350,fitColumns:true,checkOnSelect:false,
   autoRowHeight:true,nowrap:false,pagination:true,toolbar:'#zjk-salePlan-tools',
pageList:[5,10,15,20],pageSize:5">
            <thead>
            <tr class="datagrid-header-row">
                <th data-options="field:'code',width:10,align:'center',checkbox:true">编码</th>
                <th data-options="field:'theme',width:100,align:'center'">计划名称</th>
                <th data-options="field:'customer',width:60,align:'center'">负责人</th>
                <th data-options="field:'priority',width:40,align:'center'">产品策略</th>
                <th data-options="field:'type',width:50,align:'center'">价格策略</th>
                <th data-options="field:'chargePerson',width:60,align:'center'">费用预算</th>
                <th data-options="field:'exceptDate',width:80,align:'center'">审核状态</th>
                <th data-options="field:'exceptMoney',width:60,align:'center'">创建时间</th>
                <th data-options="field:'posibility',width:50,align:'center'">更新时间</th>
                <th data-options="field:'operation',width:100,align:'center'" formatter="format">操作</th>



            </tr>
            </thead>
            <tbody>
            <td>001</td>
            <td>名称1</td>
            <td>2恢复大师空间发挥司法所开发时代峰</td>
            <td>2323</td>
            <td>001</td>
            <td>审核通过</td>
            <td>2323</td>
            <td>001</td>
            </tbody>
        </table>

    </div>
    <div data-options="region:'center',title:'计划明细', border:false,iconCls:'icon-save2'" style="padding:5px;">
        <table id="zjk-salePlan-edtalis-dg" class="easyui-datagrid table-chance"  data-options="fit:true,striped:true,height:350,fitColumns:true,checkOnSelect:false,
   autoRowHeight:true,nowrap:false,pagination:true,
pageList:[5,10,15,20],pageSize:5">
            <thead>
            <tr class="datagrid-header-row">
                <th data-options="field:'code',width:50,align:'center'">产品编号</th>
                <th data-options="field:'comId',width:40,align:'center'">产品名称</th>
                <th data-options="field:'comName',width:100,align:'center'">单位</th>
                <th data-options="field:'comPower',width:60,align:'center'">售价</th>
                <th data-options="field:'comProduct',width:70,align:'center'">目标销量</th>
                <th data-options="field:'chanceId',width:50,align:'center'">目标销售额</th>
                <th data-options="field:'clientId',width:60,align:'center'">客户</th>
                <th data-options="field:'cliwreId',width:60,align:'center'">销售代表</th>
                <th data-options="field:'operation',width:90,align:'center'" >计划时间</th>

            </tr>
            </thead>
            <tbody>
            <tr class="datagrid-row">
                <td>001</td>
                <td>名称1</td>
                <td>2恢复大师空间发挥司法所开发时代峰</td>
                <td>2323</td>
                <td>001</td>
                <td>审核通过</td>
                <td>2323</td>
                <td>001</td>
                <td>324</td>



            </tr>

            </tbody>
        </table>

    </div>
</div>
</div>
<!--工具栏-->
<div id="zjk-salePlan-tools">
    <a id="zjk-add-salePlan-btn"  class="easyui-linkbutton"data-options="iconCls:'icon-mini_add2',plain:true">新建</a>
    <a id="delete-salePlan" href="#" class="easyui-linkbutton"data-options="iconCls:'icon-my_delete',plain:true">删除</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-my_edit',plain:true">编辑</a>

    <a  class="easyui-linkbutton" data-options="iconCls:'icon-my_search',plain:true">查询所有</a>

    <input class="easyui-searchbox" style="width: 200px" data-options=""/>
</div>

<div id="zjk-salePlan-add-edit-dialog" class="easyui-dialog" style="background-color:#EBEFF2;" data-options="
           modal:true,
			iconCls:'icon-save2',
			width:'70%',
			height:'100%',
			closed:true,
			href:'zjk-salePlan-form',
			shadow:true,
			bodyCls:'by',
			buttons:'#zjk-salePlan-add-edit-dialog-bb' "></div>

<div id="zjk-salePlan-add-edit-dialog-bb">
    <a href="#" id="zjk-salePlan-add-edit-dialog-bb-save" class="easyui-linkbutton" data-options="iconCls:'icon-ok2'">保存</a>
    <a href="#" id="zjk-salePlan-add-edit-dialog-bb-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel2'">关闭</a>
</div>


<script>
    $(function () {
        //打开添加竞争对手对话框
        $("#zjk-add-salePlan-btn").linkbutton({onClick:function () {
                $('#zjk-salePlan-add-edit-dialog').dialog('open').panel({
                    title:'新建销售计划'
                });
            }});
        //关闭按钮事件
        $("#zjk-salePlan-add-edit-dialog-bb-close").linkbutton({onClick:function () {
                $('#zjk-salePlan-add-edit-dialog').window('close');
            }});
        //保存按钮事件
        $("#zjk-salePlan-add-edit-dialog-bb-save").linkbutton({onClick:function () {

            }});

        //工具栏多行删除事件处理
        $("#delete-salePlan").linkbutton({
            onClick: function () {
                $.messager.confirm("询问","您确定要删除吗？",function (v) {
                    if (v){
                        var rows=$("#zjk-salePlan-dg").datagrid('getChecked');
                        if (rows.length == 0) {
                            $.messager.alert("提示","请先选择要删除的行！");
                        }else {
                            for(var i=0;i < rows.length;i++){
                                if (rows[i]){
                                    var comId = rows[i].competitor.comId;
                                    $.post('deleteCompetitor',{comId:comId},function (r) {

                                        if (r.success){
                                            $("#zjk-salePlan-dg").datagrid('reload');
                                        } else {
                                            $.messager.alert("提示",r.messager);
                                        }
                                    });
                                }
                            }
                        }

                    }

                });


            }



        });
        //操作栏事件处理
        $("#zjk-salePlan-dg").datagrid({
            onLoadSuccess:function (data) {
                $("a[name='details']").linkbutton({
                    width:40,iconCls:'icon-my_detail',plain:true
                });
                //操作栏删除事件
                $("a[name='delete']").linkbutton({
                    width: 40, iconCls: 'icon-my_delete', plain: true,
                    onClick: function () {
                        $('#zjk-salePlan-dg').datagrid({
                            onClickCell: function (index) {
                                var rows = $('#zjk-salePlan-dg').datagrid('getRows');
                                var comid = rows[index].competitor.comId;
                                $.post('deleteCompetitor', {comId: comid}, function (r) {
                                    if (r.success) {
                                        $('#zjk-salePlan-dg').datagrid('reload');
                                    } else {
                                        $.messager.alert("提示", r.message);
                                    }
                                });
                                $('#zjk-salePlan-dg').datagrid({
                                    onClickCell: function (index) {
                                    }
                                });
                            }

                        });


                    }
                });
                //修改竞争对手信息
                $("a[name='edit']").linkbutton({
                    width:40,iconCls:'icon-my_edit',plain:true,
                    onClick:function () {
                        var row = $('#zjk-salePlan-dg').datagrid('getSelected');
                        if(row){
                            $('#zjk-salePlan-add-edit-dialog').dialog({

                            });
                            $('#zjk-salePlan-add-edit-dialog').dialog('open').panel({
                                title:'修改竞争对手信息',
                                onLoad:function () {
                                    $("#zjk-competitor-f").form('load',row);
                                    $("#competitor-name").textbox({value:row.competitor.comName});
                                    $("#competitor-client-combobox").textbox({value:row.cname});
                                    $("#competitor-saleChance-combobox").textbox({value:row.chanceTheme});
                                    $("#competitor-product").textbox({value:row.competitor.comProduct});
                                    $("#competitor-price").textbox({value:row.competitor.comPrice});
                                    $("#competitor-power").combobox({value:row.competitor.comPower});
                                    $("#competitor-coping").textbox({value:row.competitor.coping});
                                    $("#competitor-remarks").textbox({value:row.competitor.remarks});
                                }
                            });
                        }
                    }
                });

            }
        });

    });
    //添加操作栏图标
    function format(value,row,index){
        var str='<a name="details" href="#" class="easyui-linkbutton " data-options="onClick:function(){$(\'#zjk-competitor-details\').window(\'open\');}"></a>'+
            '<a name="delete" href="#" class="easyui-linkbutton "></a>'+
            '<a name="edit" href="#" class="easyui-linkbutton zjk-edit-competitor-btn"></a>';
        return str;

    }

</script>

</body>
</html>
